package org.hot100_1;

import org.algorithm.List.ListNode;

import java.util.ArrayList;
import java.util.List;

public class leetcode24 {
    public boolean isPalindrome(ListNode head) {

        List<Integer> list =new ArrayList<>();

        ListNode temp = head;
        while (temp!=null){
            list.add(temp.val);
            temp=temp.next;
        }

        int left = 0;
        int right = list.size()-1;

        while (left<right){
            if (list.get(left)!=list.get(right)){
                return false;
            }
            left++;
            right--;
        }

        return true;
    }
}
